package bookshop.service.impl;

import java.util.List;

import bookshop.dao.DaoFactory;
import bookshop.dao.ManagerDao;
import bookshop.domain.Manager;
import bookshop.service.ManagerService;
import bookshop.service.helper.ManagerQueryHelper;
import bookshop.utils.Page;

public class ManagerServiceImpl implements ManagerService {

	/** 
	 * 根据提供的登陆id获取管理员信息
	 */
	public Manager getManagerById(String loginId) {
		
	    ManagerDao managerDao=(ManagerDao)DaoFactory.getDao("managerDao");
		
		return managerDao.getManagerById(loginId);
	}
	public void createManager(Manager manager) {
	    
		ManagerDao ctgDao = (ManagerDao) DaoFactory.getDao("managerDao");
		ctgDao.addManager(manager);
    

}
	@Override
	public List<Manager> loadall() {
		ManagerDao managerDao = (ManagerDao) DaoFactory.getDao("managerDao");
		return managerDao.loadall();
	}
	@Override
	public void updateManager(Manager manager) {
		 ManagerDao managerDao=(ManagerDao)DaoFactory.getDao("managerDao");
		 managerDao.update(manager);
		
	}

	@Override
	public void deleteManager(String loginId) {
		 ManagerDao managerDao=(ManagerDao)DaoFactory.getDao("managerDao");
		 managerDao.delete(loginId);
	}

	@Override
	public void up_status(Manager manager) {
		 ManagerDao managerDao=(ManagerDao)DaoFactory.getDao("managerDao");
		 managerDao.up_status(manager);
		
	}
	@Override
	public Page loadManagerByCondition(ManagerQueryHelper helper,Page page) {
		
		ManagerDao managerDao=(ManagerDao)DaoFactory.getDao("managerDao");
		page.setTotalRecNum(managerDao.countManagerByCondition(helper));
		page.setPageContent(managerDao.getScopedManager(helper, page.getStartIndex(), page.getPageSize()));

		return page;
		
	}
}